/**
 * Created by Administrator on 2016/7/8.
 */

var zhujian = null;
	function shujujz(id){
		zhujian = id;
		//获取页面间id
		var sendData={
			"id":zhujian
		};
		$.ajax({
			//请求方式为get
			type:"POST",
			//获取json文件路径
			url:"./yuangong/getById",
			//传送数据
			data:sendData,
			
			//请求成功完成后要执行的方法
			success: function(data){
				//设置input只读
				var glabel ="<label class='control-label' style='font-weight:normal'>"+data.shoujihm+"</label>";
				glabel = glabel +"<input id='shoujihm' name='shoujihm' type='hidden' value='"+data.shoujihm+"'/>" ;
				glabel = glabel +"<input id='id' name='id' type='hidden' value='"+zhujian+"'/>"
				$(".input-shoujihm").html(glabel);
				//设置姓名
				$("#xingming").text(data.xingming);
				$("#yishengbm").val(data.yishengbm);
				//隐藏密码
				if($("#xingming").val() !=""){
					$(".have").css("display","none");
				}
				 var quanxian = data.quanxian.split(",");
				 $.each(quanxian,function(i,v){
	                	$(".on-check1:eq("+(v-1)+")").addClass("c-check2");
	                    $("input[name='quanxian']:eq("+(v-1)+")").prop('checked', true);
	                });
				//设置禁用状态
				 if( data.jinyongbz == 0 || data.jinyongbz =="" ||  data.jinyongbz==null ||data.jinyongbz == undefined){
					//禁用
					    $(".f-bz:eq(1)").addClass("on");
	                    $("input[name='jinyongbz']:eq(1)").attr("checked",true);
	                }
	                else{//启用
	                    $(".f-bz:eq(0)").addClass("on");
	                    $("input[name='jinyongbz']:eq(0)").attr("checked",true);
	                }
				 var shifoulb = data.shifoulb;
				 //checkbox默认
				 if( data.shifoulb  == 1){
	           		$("label[name='jinyongbz2']").addClass("r-disable");
	           		$("label[name='quanxian6']").addClass("c-disable");
	           		 shifoulb = '老板';
				 }   
				//radios默认
				 if(  data.shifoulb  == 0 ){
	           		    shifoulb = '员工';
	           		 }   
				 if(data.keshimc != '' && data.keshimc != null) {
					 $("#keshi").text(data.keshimc);
					 $("#hikeshiid").val(data.keshiid);
				 }
				 $('#zhensuogx').text(shifoulb);
				 $('#denglucs').text(data.denglucs+'次');
				 $('#jirsj').text(data.jiaruzssjstr);
				 $('#zuihoudlsj').text(data.zuihoudlsjstr);
			}
		
		});
	}
	$("#keshi").click(function(){
		$.post(path+"/keshi/getZSKeshixxByZsId",{},function(result){
			if(result.succsess) {
				var content = '';
				$(result.data).each(function(){
					content += '<li value="'+this.id+'">'+this.keshimc+'</li>';
				});
				$(".keshiul").html(content);
			}
		});
	});
	//科室下拉
	$(document).on('click','.keshiul li',function(){
		$("#hikeshiid").val($(this).attr("value"));
		$(this).parent().parent().find('#keshi').text($(this).text());
		$(this).parent().css('display','none');
	})

